
package datos;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Ing. Monica Merlo, Ing. Agustin  Fernandez
 */
@Entity
@Table(name = "empresaContratista")
@NamedQueries({@NamedQuery(name = "EmpresaContratista.encontrarTodosNombre", query = "SELECT e.razonSocial FROM EmpresaContratista e ORDER BY e.razonSocial"),
@NamedQuery(name = "EmpresaContratista.findByRazonSocial", query = "SELECT e FROM EmpresaContratista e WHERE e.razonSocial = :razon"),
@NamedQuery(name = "EmpresaContratista.findAll", query = "SELECT e FROM EmpresaContratista e"),
@NamedQuery(name = "EmpresaContratista.findById", query = "SELECT e FROM EmpresaContratista e WHERE e.id = :id"),
@NamedQuery(name = "EmpresaContratista.findByCuit", query = "SELECT e FROM EmpresaContratista e WHERE e.cuit = :cuit"),
@NamedQuery(name = "EmpresaContratista.findByEmpresaModificar", query = "SELECT e FROM EmpresaContratista e WHERE e.razonSocial = :razon AND e.id <> :id"),
@NamedQuery(name = "EmpresaContratista.findByPaginaWeb", query = "SELECT e FROM EmpresaContratista e WHERE e.paginaWeb = :paginaWeb"),
@NamedQuery(name = "EmpresaContratista.findByTelefono", query = "SELECT e FROM EmpresaContratista e WHERE e.telefono = :telefono")})
public class EmpresaContratista implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "cuit")
    private String cuit;
    @Basic(optional = false)
    @Lob
    @Column(name = "razonSocial")
    private String razonSocial;
    @Lob
    @Column(name = "email")
    private String email;
    @Lob
    @Column(name = "paginaWeb")
    private String paginaWeb;
    @Column(name = "telefono")
    private String telefono;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idEmpresa")
    private Collection<ResponsableObra> responsableObraCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idEmpresaContratista")
    private Collection<Contrato> contratoCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idEmpresa")
    private Collection<TelefonoEmpresa> telefonoEmpresaCollection;
    @OneToMany(mappedBy = "idEmpresa")
    private Collection<Obra> obraCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idEmpresaContratista")
    private Collection<Certificado> certificadoCollection;
    @JoinColumn(name = "idDomicilio", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Domicilio idDomicilio;
    @JoinColumn(name = "idPais", referencedColumnName = "id")
    @ManyToOne
    private Pais idPais;

    public EmpresaContratista() {
    }

    public EmpresaContratista(Integer id) {
        this.id = id;
    }

    public EmpresaContratista(Integer id, String cuit, String razonSocial) {
        this.id = id;
        this.cuit = cuit;
        this.razonSocial = razonSocial;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCuit() {
        return cuit;
    }

    public void setCuit(String cuit) {
        this.cuit = cuit;
    }

    public String getRazonSocial() {
        return razonSocial;
    }

    public void setRazonSocial(String razonSocial) {
        this.razonSocial = razonSocial;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPaginaWeb() {
        return paginaWeb;
    }

    public void setPaginaWeb(String paginaWeb) {
        this.paginaWeb = paginaWeb;
    }

    public String getTelefono() {
        return telefono;
    }

    public void setTelefono(String telefono) {
        this.telefono = telefono;
    }

    public Collection<ResponsableObra> getResponsableObraCollection() {
        return responsableObraCollection;
    }

    public void setResponsableObraCollection(Collection<ResponsableObra> responsableObraCollection) {
        this.responsableObraCollection = responsableObraCollection;
    }

    public Collection<Contrato> getContratoCollection() {
        return contratoCollection;
    }

    public void setContratoCollection(Collection<Contrato> contratoCollection) {
        this.contratoCollection = contratoCollection;
    }

    public Collection<TelefonoEmpresa> getTelefonoEmpresaCollection() {
        return telefonoEmpresaCollection;
    }

    public void setTelefonoEmpresaCollection(Collection<TelefonoEmpresa> telefonoEmpresaCollection) {
        this.telefonoEmpresaCollection = telefonoEmpresaCollection;
    }

    public Collection<Obra> getObraCollection() {
        return obraCollection;
    }

    public void setObraCollection(Collection<Obra> obraCollection) {
        this.obraCollection = obraCollection;
    }

    public Collection<Certificado> getCertificadoCollection() {
        return certificadoCollection;
    }

    public void setCertificadoCollection(Collection<Certificado> certificadoCollection) {
        this.certificadoCollection = certificadoCollection;
    }

    public Domicilio getIdDomicilio() {
        return idDomicilio;
    }

    public void setIdDomicilio(Domicilio idDomicilio) {
        this.idDomicilio = idDomicilio;
    }

    public Pais getIdPais() {
        return idPais;
    }

    public void setIdPais(Pais idPais) {
        this.idPais = idPais;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof EmpresaContratista)) {
            return false;
        }
        EmpresaContratista other = (EmpresaContratista) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "datos.EmpresaContratista[id=" + id + "]";
    }

}
